package edu.whut.jdk8.instruct;
/*
ChronoUnit类，经常用的
 */

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class ChronoUnitDemo {
    public static void main(String[] args) {
        LocalDateTime today = LocalDateTime.now();
        System.out.println(today);

        LocalDateTime otherDate = LocalDateTime.of(2024,10,14,0,0,0);
        System.out.println(otherDate);

        System.out.println(ChronoUnit.YEARS.between(otherDate,today));
        System.out.println(ChronoUnit.MONTHS.between(otherDate,today));
        System.out.println(ChronoUnit.WEEKS.between(otherDate,today));
        System.out.println(ChronoUnit.DAYS.between(otherDate,today));
        System.out.println(ChronoUnit.HOURS.between(otherDate,today));
        System.out.println(ChronoUnit.MINUTES.between(otherDate,today));
        System.out.println(ChronoUnit.SECONDS.between(otherDate,today));
        System.out.println(ChronoUnit.MILLIS.between(otherDate,today));
        System.out.println(ChronoUnit.MICROS.between(otherDate,today));
        System.out.println(ChronoUnit.HALF_DAYS.between(otherDate,today));
        System.out.println(ChronoUnit.DECADES.between(otherDate,today));//十年数
        System.out.println(ChronoUnit.CENTURIES.between(otherDate,today));//世纪数
        System.out.println(ChronoUnit.MILLENNIA.between(otherDate,today));//千年数
        System.out.println(ChronoUnit.ERAS.between(otherDate,today));//纪元数
    }
}
